package server;

import java.util.HashMap;
import java.util.Map;

public class Mapper {

    private Host host;

    public Mapper() {
        this.host = new Host();
    }

    public Host getHost() {
        return host;
    }

    public void setHost(Host host) {
        this.host = host;
    }

}

class Host {
    private Map<String, Context> contextMap = new HashMap<>();

    public void addContext(Context context) {
        contextMap.put(context.getContextName(), context);
    }

    public Context getContext(String contextName) {
        return contextMap.get(contextName);
    }

}

class Context {
    private String contextName;
    private Map<String, Wrapper> wrapperMap = new HashMap<>();

    public void addWrapper(Wrapper wrapper) {
        wrapperMap.put(wrapper.getUrlPattern(), wrapper);
    }

    public Wrapper getWrapper(String urlPattern) {
        return wrapperMap.get(urlPattern);
    }

    public String getContextName() {
        return contextName;
    }

    public void setContextName(String contextName) {
        this.contextName = contextName;
    }
}

class Wrapper {
    private String urlPattern;
    private HttpServlet servlet;

    public HttpServlet getServlet() {
        return servlet;
    }

    public void setServlet(HttpServlet servlet) {
        this.servlet = servlet;
    }

    public String getUrlPattern() {
        return urlPattern;
    }

    public void setUrlPattern(String urlPattern) {
        this.urlPattern = urlPattern;
    }
}
